<html>
<head><meta charset="utf-8"><title>active attribute spans · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/active.20attribute.20spans.html">active attribute spans</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="239182608"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/active%20attribute%20spans/near/239182608" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/active.20attribute.20spans.html#239182608">(May 18 2021 at 01:02)</a>:</h4>
<p>Is there any way to get the span of an active attribute after it has been removed from an item? (For example, <code>#[derive]</code>)</p>
<p>I'm looking at a diagnostic placement problem where it is trying to find a location to place <code>use</code> suggestions. However, since active attributes seem to be missing from <code>item.attrs</code>, there doesn't seem to be a way to correctly find a position that is just "before" an item.</p>



<a name="239183168"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/active%20attribute%20spans/near/239183168" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/active.20attribute.20spans.html#239183168">(May 18 2021 at 01:09)</a>:</h4>
<p>We currently discard attributes after expansion</p>



<a name="239183183"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/active%20attribute%20spans/near/239183183" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/active.20attribute.20spans.html#239183183">(May 18 2021 at 01:09)</a>:</h4>
<p>I don't think there's currently any way to retreive them once they're discarded</p>



<a name="239183315"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/active%20attribute%20spans/near/239183315" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/active.20attribute.20spans.html#239183315">(May 18 2021 at 01:10)</a>:</h4>
<p>Hm, that's what I suspected.  I'll try a different approach of looking for a span <em>after</em> an item instead of <em>before</em>.</p>



<a name="239183336"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/active%20attribute%20spans/near/239183336" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/active.20attribute.20spans.html#239183336">(May 18 2021 at 01:11)</a>:</h4>
<p>thanks!</p>



<a name="239240301"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/active%20attribute%20spans/near/239240301" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/active.20attribute.20spans.html#239240301">(May 18 2021 at 12:00)</a>:</h4>
<p>If you have an <code>ExpnId</code> of that attribute then something like <code>expn_id.expn_data().call_site</code> should work.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>